home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
The X-Philes (2nd Revision)
/
The X-Philes Number 1 (1995).iso
/
xphiles
/
hp48_1
/
mod.mul
< prev
next >
Wrap
Text File
|
1995-03-23
|
2KB
|
60 lines
Article 1362 of comp.sys.handhelds:
Path: en.ecn.purdue.edu!noose.ecn.purdue.edu!samsung!uunet!mcsun!hp4nl!charon!cwi.nl
From: jurjen@cwi.nl (Jurjen NE Bos)
Newsgroups: comp.sys.handhelds
Subject: Modulo computations on 48SX
Keywords: Number theory
Message-ID: <2131@charon.cwi.nl>
Date: 18 Sep 90 08:18:24 GMT
Sender: news@cwi.nl
Organization: STORC, Veldhoven
Lines: 45
This article is meant for factorization and number theory freaks.
I wrote a machine code program that does modulo multiplication for
binaries. The program is equivalent to the RPL
\<< ROT ROT * SWAP DUP2 / * - \>>,
except that the latter program only works if the intermediate product is
smaller than 2^64.
This machine code version does not have this problem.
Convert it with Bill Wickes' program ASC\->, and store in MULMOD.
"D9D200FE8111920BBB00CCD20470008FD8F35100208F2D7608FD8F35101208F2
D7608FD8F35AF8119AF7118AF082281F83201A704709F250B7AA754709F550B7
197F6D8D59E35B21305C54"
(28S owners please wait: I am working on a 28S version.)
Usage:
enter #a #b #m MULMOD to get (#a*#b) MOD #m
All arguments must be binaries.
#a must be < #m to make sure that the result is < #m.
#b and #m are unrestricted.
All arguments are checked, so that you don't have to be afraid for
mistakes. You'll get a nice "Too Few Arguments" or "Bad Argument Type"
if applicable.
Remark: it is only tested on a version D.
If you have another version, you're probably safe. To be sure, check
out memory location 53F8D. It should contain 174E773DF1C4143 for the
program to work.
A nice example of the use of MULMOD is the "Random imitator".
The random generator uses internally a seed of 15 digits, and can be
imitated using the program:
\<< #2851130928467d R #1000000000000000 MULMOD DUP 'R' STO B->R 1E15 /
\>>
Seed the random generator by replacing
.xxxxxxxxxxxxEyy RDZ
by
#xxxxxxxxxxxxyy1 'R' STO
You can also produce the reverse of the random sequence replacing
the factor 2851130928467 by 953992389123803.
Have fun!
--
| | "Never imagine yourself not to be otherwise than what |
| Jurjen N.E. Bos | it might appear to others that what you were or might |
| | have been was not otherwise than what you had been |
| jurjen@cwi.nl | would have appeared to them to be otherwise." |